From: Jyrki Gadinger Date: Mon, 17 Mar 2025 14:35:49 +0000 (+0100) Subject: gui: fix dark mode change on Windows 10 with universal style X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~1^2~6^2 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success/%22http:/www.example.com/cgi/success?a=commitdiff_plain;h=6898f86aeb1f50656dea8150638c790f59d33805;p=nextcloud-desktop.git gui: fix dark mode change on Windows 10 with universal style The _Universal_ QML style has a theme that uses the colour scheme from the system. This can be set by either configuring `qtquickcontrols2.conf` or setting the environment variable `QT_QUICK_CONTROLS_UNIVERSAL_THEME=System`. Unfortunately, due to [QTBUG-128825], setting the theme in the configuration file/environment variable results in the dark/light mode setting only be set during startup, not during runtime. Not ideal, but still better than not having a broken dark mode theme at all. Fixes #7991 [QTBUG-128825]: https://bugreports.qt.io/browse/QTBUG-128825 Signed-off-by: Jyrki Gadinger --- diff --git a/src/gui/main.cpp b/src/gui/main.cpp index 46fcfcc4d..dbbffc9fd 100644 --- a/src/gui/main.cpp +++ b/src/gui/main.cpp @@ -87,6 +87,10 @@ int main(int argc, char **argv) if (QOperatingSystemVersion::current().version() < QOperatingSystemVersion::Windows11.version()) { qmlStyle = QStringLiteral("Universal"); widgetsStyle = QStringLiteral("Fusion"); + if (qEnvironmentVariableIsEmpty("QT_QUICK_CONTROLS_UNIVERSAL_THEME")) { + // initialise theme with the light/dark mode setting from the OS + qputenv("QT_QUICK_CONTROLS_UNIVERSAL_THEME", "System"); + } } else { qmlStyle = QStringLiteral("FluentWinUI3"); widgetsStyle = QStringLiteral("windows11");